﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Extentions;

namespace LibNiconico.NiconicoApi.PlayerStatus
{
    public sealed partial class NicoPlayerStatus
    {
        public sealed partial class InternalClasses
        {
            /// <summary>
            /// ツイッター関連情報
            /// </summary>
            public class Twitter
            {
                /// <summary>
                /// 放送が有効かの判定?
                /// </summary>
                public bool LiveEnabled { get; private set; }

                /// <summary>
                /// ビップモードの数?
                /// </summary>
                public int VipModeCount { get; private set; }

                /// <summary>
                /// 生放送URL
                /// </summary>
                public Uri LiveApiUrl { get; private set; }

                internal static Twitter Parse(XElement element)
                {
                    Twitter twitter = XElementExtention.Parse(element, "twitter", item =>
                    {
                        return new Twitter
                        {
                            LiveEnabled = XElementExtention.GetElementAsBool(item, "live_enabled"),
                            VipModeCount = XElementExtention.GetElementAsInt(item, "vip_mode_count"),
                            LiveApiUrl = XElementExtention.GetElementAsUri(item, "live_api_url")
                        };
                    });

                    return twitter == null ? new Twitter() : twitter;
                }

                internal Twitter() 
                {
                    this.LiveEnabled = false;
                    this.VipModeCount = 0;
                    this.LiveApiUrl = default(Uri);
                }

            }
        }
    }
}
